require('../../assets/css/index.js')
require('../../assets/fonts/font/iconfont.css')
require('../../assets/lib/swiper/swiper-bundle.css')
let Swiper = require('../../assets/lib/swiper/swiper-bundle.js')
require('../../utils/local.js')
let https = require('../../utils/https.js')

// 引入公共js
let dom = require('../../utils/dom.js')
const local = require('../../utils/local.js')
//引入当前页面的less文件
require('./badge.less')



//4.当前页面中的js
dom.ready(function () {
    //定义一个数组,保存所有徽章
    let allArr = [
        require('../../assets/imgs/mybadge09.jpg'),
        require('../../assets/imgs/mybadge01.jpg'),
        require('../../assets/imgs/mybadge02.jpg'),
        require('../../assets/imgs/mybadge03.jpg'),
        require('../../assets/imgs/mybadge04.jpg'),
        require('../../assets/imgs/mybadge05.jpg'),
        require('../../assets/imgs/mybadge06.jpg'),
        require('../../assets/imgs/mybadge07.jpg'),
        require('../../assets/imgs/mybadge08.jpg')
    ]

    //获取接口数据
    function getBadge() {
        https.get('/api/exercise/badge', {}, function (res) {
            if (res.errno == 0) {
                res.data.map(v => {
                    console.log(v);

                    dom.getEle('.id').innerHTML = v.id;
                    // dom.getEles('.fdcolumn').innerHTML=v.date

                    dom.getEle('.myBadge').innerHTML += `<li><img src="${allArr[v.id]}" alt=""><h4>${v.name}</h4></li>`;
                    // })

                })
                    

            }
        })
    }
    getBadge();
    dom.getEle(".icon-guanbi").addEventListener("click",function(){
        window.history.go(-1); 
    })
})
